using System;
using UnityEngine;

[Serializable]
public struct FloatRange
{
	public float min;

	public float max;

	public float avg
	{
		get
		{
			return (min + max) * 0.5f;
		}
	}

	public float Clamp(float value)
	{
		return Mathf.Clamp(value, min, max);
	}

	public float InverseLerp(float value)
	{
		return Mathf.InverseLerp(min, max, value);
	}

	public float Random()
	{
		return UnityEngine.Random.Range(min, max);
	}

	public float Lerp(float value)
	{
		return Mathf.Lerp(min, max, value);
	}

	public bool isIncluding(float value)
	{
		return value >= min && value <= max;
	}

	public bool IsIntersecting(FloatRange range)
	{
		return isIncluding(range.min) || isIncluding(range.max) || range.isIncluding(min) || range.isIncluding(max);
	}

	public float LerpMinMax(float value)
	{
		value = Mathf.Clamp(value, -1f, 1f);
		float num = ((!(Mathf.Sign(value) > 0f)) ? min : max);
		return num * Mathf.Abs(value);
	}

	public float InverseLerpZeroCenter(float value)
	{
		return Mathf.Sign(value) * Mathf.InverseLerp(0f, (!(value < 0f)) ? max : min, value);
	}

	public void Add(FloatRange range)
	{
		min += range.min;
		max += range.max;
	}

	public void Sub(FloatRange range)
	{
		min -= range.min;
		max -= range.max;
	}

	public override string ToString()
	{
		return string.Format("[{0},{1}]", min, max);
	}
}
